-
Notifications
You must be signed in to change notification settings - Fork 372
Feat: Pre-quantized LLM model support #3740
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
62cb0f2
to
1f1cf7f
Compare
return model | ||
|
||
|
||
class TensorRTQuantizedLinear(torch.nn.Module): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@peri044 Is this something we might want to upstream to ModelOpt in the future?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or pull into main torch-tensorrt as a pass?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess its somewhat HF specific, so remaining in this tool would make sense but are there some parts we could make generic for any sort of quantization workflow (e.g. torchao)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I think quantize_model() can be moved to function like torch_tensorrt.dynamo.quantize(). Currently investigating how to separate the calibration data path from the quantization logic
tools/llm/quantize_utils.py
Outdated
|
||
hf_quant_algo = hf_quant_config.pop("quant_algo", None) | ||
if hf_quant_algo != "FP8" and hf_quant_algo != "NVFP4": | ||
raise RuntimeError("Only FP8 or NVFP4 quantization is supported") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How would it be different for MXFP4?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looked at quantization cfg in modelopt
NVFP4_DEFAULT_CFG NVFP4 has E4M3 scales and a block size is 16.
MXFP4_DEFAULT_CFG MXFP4 has E8M0 scales and a block size is 32.
19a4070
to
303775e
Compare
Description
Support pre-quantized HF models and post-training quantization (PTQ) option for run_llm.py
Fixes # (issue)
Type of change
Checklist: